home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / pmode / 386p_099 / example1.asm < prev    next >
Encoding:
Assembly Source File  |  1994-05-03  |  7.7 KB  |  257 lines

  1. ; 386POWER example program #0.
  2. ; Install a mouse driver, compile, and run.
  3. ; When run, use the left mouse button to draw. Any key exits.
  4.         .386p
  5.  
  6. code32  segment para public use32
  7.         assume cs:code32, ds:code32
  8.  
  9. include 386power.inc
  10. include 386video.inc
  11. include 386file.inc
  12.  
  13. public  _Main
  14.  
  15. CR equ 0dh
  16. LF equ 0ah
  17.  
  18. ; DATA
  19. eraw_text       db      ' Voc2RAW result ( 0 == OK)',0
  20. raw_text       db      ' RAW data size',0
  21. ex_text         db      'TEST ONE for 386POWER',CR,LF
  22.                 db      'Testing PWM sound system',CR,LF
  23.                 db      'PRESS & RELEASE ESC TO EXIT',0
  24.                 
  25. lo_mem          db      'AVAILABLE DOS MEMORY',0
  26. hi_mem          db      'AVAILABLE EXTENDED MEMORY',0
  27.  
  28. fl_mem          db      'SIZE OF TIGER.VOC FILE',0
  29. man_text        db      'RUNNING UNDER ',0
  30. systypestr      db      'VCPI','DPMI'
  31. hextuff         db      '0123456789ABCDEF'
  32. d_text          db      8 dup(0)
  33. fname           db      'tiger.voc',0
  34.  
  35. ; CODE
  36.  
  37. PutText:  ; put ECX chars to screen with attr AH
  38.         push edx
  39.         mov  edx,edi
  40. XPutText:        
  41.         lodsb
  42.         cmp al,0
  43.         je CHend
  44.         cmp al,CR
  45.         jne noCR
  46.         mov edi,edx
  47.         jmp nxCH
  48. noCR:   cmp al,LF
  49.         jne noLF
  50.         add edx,160
  51.         add edi,160
  52.         jmp nxCH
  53. noLF:                
  54.         stosw
  55. nxCH:        
  56.         loop XPutText
  57. CHend:        
  58.         pop edx
  59.         ret
  60.  
  61. ;----------------------
  62. d2text: ; edx = dword to convert to hex
  63.         push ebx
  64.         push ecx
  65.         push edi
  66.         
  67.         xor ebx,ebx
  68.         mov edi, offset d_text
  69.         mov ecx, 8
  70.         add edi, 7
  71.         std
  72. txpit:        
  73.         mov ebx,edx
  74.         and ebx,0Fh
  75.         mov al,[ebx+hextuff]
  76.         stosb
  77.         shr edx,4
  78.         loop txpit
  79.         
  80.         pop edi
  81.         pop ecx
  82.         pop ebx
  83.         cld
  84.         ret
  85.         
  86. LargestFree DD 48 dup(0FFFFFFFFh)
  87.  
  88. ;═════════════════════════════════════════════════════════════════════════════
  89. _Main:  mov al,10h
  90.         mov V86ax,0003 ; text mode 80 columns, 16 colors
  91.         int 33h
  92.         
  93.         sti ; enable interrupts
  94.         
  95.         @rlp edi,0b8000h     ; get relative pointer to text screen
  96.         mov ecx,(80*25)/2    ; and clear it
  97.         mov eax,0            ;
  98.         rep stosd            ;
  99.  
  100.         @rlp edi,0b8000h+(50*2)    ; put type of system
  101.         mov esi,offset man_text    ;
  102.         mov ecx,-1                 ;
  103.         mov ah,14                  ;
  104.         call PutText               ;
  105.         movzx esi,_386Man          ;
  106.         and esi,1                  ; all the other bits will be 0, but
  107.         lea esi,[esi*4+systypestr] ; what the heck!
  108.         mov ecx,4                  ;
  109.         mov ah,15                  ;
  110.         call PutText               ;
  111.         
  112.         
  113.         mov edx,_HiMemTop          ; write allocated ext. mem. size
  114.         sub edx,_HiMemBase         ;
  115.         call d2text                ;
  116.                                    ;
  117.         @rlp edi,0b8000h           ;
  118.         mov esi,offset d_text      ;
  119.         mov ecx,8                  ;
  120.         mov ah,13                  ;
  121.         call PutText               ;
  122.                                    ;
  123.         @rlp edi,(0b8000h+18)      ;
  124.         mov esi,offset hi_mem      ;
  125.         mov ecx,-1                 ;
  126.         mov ah,13                  ;
  127.         call PutText               ;
  128.         
  129.         mov edx,_LoMemTop          ; write available low mem size
  130.         sub edx,_LoMemBase         ;
  131.         call d2text                ;
  132.                                    ;
  133.         @rlp edi,(0b8000h+160)     ;
  134.         mov esi,offset d_text      ;
  135.         mov ecx,8                  ;
  136.         mov ah,12                  ;
  137.         call PutText               ;
  138.                                    ;
  139.         @rlp edi,(0b8000h+160+18)  ;
  140.         mov esi,offset lo_mem      ;
  141.         mov ecx,-1                 ;
  142.         mov ah,12                  ;
  143.         call PutText               ;
  144.  
  145.  
  146.         mov esi, offset fname    ; load at _HiMemBase file called fname
  147.         call _FLoad              ; BUT do not update _HiMemBase
  148.         ; eax == file size
  149.         
  150.         pushad                         ; write size of file loaded
  151.         mov edx,eax                    ;
  152.         call d2text                    ;
  153.                                        ;
  154.         @rlp edi,(0b8000h+(160*2))     ;
  155.         mov esi,offset d_text          ;
  156.         mov ecx,8                      ;
  157.         mov ah,11                      ;
  158.         call PutText                   ;
  159.                                        ;
  160.         @rlp edi,(0b8000h+(160*2)+18)  ;
  161.         mov esi,offset fl_mem          ;
  162.         mov ecx,-1                     ;
  163.         mov ah,11                      ;
  164.         call PutText                   ;
  165.         popad                          ;
  166.         
  167.         cmp eax,-1       ; does we had problems?
  168.         je skipsound     ;
  169.         
  170.         pushad  ; save 
  171.         
  172.         call _InstallPWM      ; install PWM sound system and initialize
  173.                               ; the voc converter table
  174.         
  175.         mov edi,_LoMemBase
  176.         mov esi,_HiMemBase
  177.         call _Voc2RAW    ; convert into PWM count format
  178.         
  179.         and eax,0FFh                ; display Voc2RAW result
  180.         mov edx,eax                 ;
  181.         call d2text                 ;
  182.                                     ;
  183.         @rlp edi,(0b8000h+(160*8))  ;
  184.         mov esi,offset d_text       ;
  185.         mov ecx,8                   ;
  186.         mov ah,11                   ;
  187.         call PutText                ;
  188.         
  189.         @rlp edi,(0b8000h+(160*8)+20) ; explanatory text
  190.         mov esi,offset eraw_text      ;
  191.         mov ecx,0                     ;
  192.         mov ah,11                     ;
  193.         call PutText                  ;
  194.         
  195.         popad
  196.         
  197.         mov edi,_LoMemBase ; point to "pwm" data
  198.         
  199.         mov edx,[edi]                 ; write lenght of "raw" data
  200.         call d2text                   ;
  201.                                       ;
  202.         @rlp edi,(0b8000h+(160*9))    ;
  203.         mov esi,offset d_text         ;
  204.         mov ecx,8                     ;
  205.         mov ah,11                     ;
  206.         call PutText                  ;
  207.                                       ;
  208.         @rlp edi,(0b8000h+(160*9)+20) ;
  209.         mov esi,offset raw_text      ;
  210.         mov ecx,0                     ;
  211.         mov ah,11                     ;
  212.         call PutText                  ;
  213.         mov edi,_LoMemBase
  214.         mov eax,[edi]
  215.         mov _DSoundLen,eax  ;  set lenght of digitized samples
  216.         mov _SoundLen,eax   ;
  217.         add edi,4
  218.         mov _DSoundPtr,edi ; set pointers
  219.         mov _SoundPtr,edi  ;
  220.         
  221.         mov _DSoundOn,1  ; turn on repetition of default sound
  222.         
  223.         mov _SoundOn,1   ; turn on sound
  224.         
  225.         
  226.         
  227. skipsound:       
  228.         @rlp edi,(0b8000h+(160*22)+(40*2)) ; explain this test
  229.         mov esi,offset ex_text             ;
  230.         mov ecx,-1                         ;
  231.         mov ah,10                          ;
  232.         call PutText                       ;
  233.         
  234.         call _InstallRKB ; install raw keyboard
  235.         
  236. kkey:        
  237.         call _WaitKey     ; wait fo a key press
  238.  
  239.         mov edi,offset _RKB
  240.         cmp byte ptr [edi+_ESC],02
  241.         jne kkey
  242. thend:        
  243.         @rlp edi,0b8000h      ; restore default screen attributes
  244.         mov ecx,2000          ;
  245.         mov al,07             ;
  246. defcolor:                     ;
  247.         inc edi               ;
  248.         stosb                 ;
  249.         loop defcolor         ;
  250.         
  251.         jmp _Exit
  252.  
  253.  
  254. code32  ends
  255.         end
  256.  
  257.